package com.kh.statistics.video.helper;

import java.math.RoundingMode;
import java.text.NumberFormat;

/**
 * @BelongsProject: statistics
 * @BelongsPackage: com.kh.statistics.video.helper
 * @Author: Hong.Kong
 * @CreateTime: 2024-05-10  11:22
 * @Description: TODO
 * @Version: 1.0
 */
public class NumberHelper {
    public static String doubleFormat(double number) {
        NumberFormat nf = NumberFormat.getNumberInstance();
// 保留两位小数
        nf.setMaximumFractionDigits(4);
        // 如果不需要四舍五入，可以使用RoundingMode.DOWN
        nf.setRoundingMode(RoundingMode.UP);
        return nf.format(number);
    }
}
